#pragma once
#include<vector>

using namespace std;

class Mapchik{
	public:

		Mapchik(){
			M.resize(1);
			M[0] = 0;
			K = 1;
		}

		int& operator[] (int index)
		{
			int indexnew = index;
			if(index > 0) indexnew = 2*index;
			if(index < 0) indexnew = -2*index - 1;
			while(indexnew >= M.size())RES(0);
			return M[indexnew];
		}

private:
		void RES(int new_values)
		{
			M.resize(2*K);
			for(int i = K; i < 2*K; ++i) M[i] = new_values;
			K *= 2;
		}

		int size() const 
		{
			return (M.size() + 1)/2;
		}

	vector<int> M;
	int K;
};